home *** CD-ROM | disk | FTP | other *** search
/ Aminet 38 / Aminet 38 (2000)(Schatztruhe)[!][Aug 2000].iso / Aminet / util / moni / Scout-src.lha / src / objects / scout_libs.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-03-09  |  20.3 KB  |  662 lines

  1. /**
  2.  * Scout - The Amiga System Monitor
  3.  *
  4.  *------------------------------------------------------------------
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  * You must not use this source code to gain profit of any kind!
  21.  *
  22.  *------------------------------------------------------------------
  23.  *
  24.  * @author Andreas Gelhausen
  25.  * @author Richard Körber <rkoerber@gmx.de>
  26.  */
  27.  
  28.  
  29.  
  30. #include "scout_libs.h"
  31.  
  32. extern struct ExecBase        *SysBase;
  33. extern struct Library         *IdentifyBase;
  34. extern struct Library         *GfxBase;
  35. extern struct IntuitionBase   *IntuitionBase;
  36.  
  37. int  libcnt,devcnt,rescnt;
  38.  
  39. struct Remember *LibRememberKey,*DevRememberKey,*ResRememberKey;
  40.  
  41. __asm LONG liblist_dspfunc(register __a2 char **array, register __a1 struct LibEntry *libentry, register __a0 struct Hook *hook) {
  42.    if (libentry) {
  43.       *array++ = libentry->lib_address;
  44.       *array++ = libentry->lib_name;
  45.       *array++ = libentry->lib_pri;
  46.       *array++ = libentry->lib_ocnt;
  47.       *array++ = libentry->lib_rcnt;
  48.       *array++ = libentry->lib_type;
  49.       *array   = NULL;
  50.    } else {
  51.       *array++ = ESC "bAddress";
  52.       *array++ = ESC "bln_Name";
  53.       *array++ = ESC "bln_Pri";
  54.       *array++ = ESC "bOpenC";
  55.       *array++ = ESC "bRPC";
  56.       *array++ = ESC "bln_Type";
  57.       *array   = NULL;
  58.    }
  59.    return(0);
  60. }
  61.  
  62. struct Hook liblist_dsphook = {
  63.  {NULL, NULL},
  64.  (ULONG (* )())liblist_dspfunc,
  65.  NULL, NULL
  66. };
  67.  
  68. int TestResource (struct Library *lib) {
  69.    char  *name;
  70.  
  71.    name = lib->lib_Node.ln_Name;
  72.  
  73.    if ((stricmp (name, FILESYSTEM_RESNAME)) && (stricmp (name, CARD_RESNAME)) && \
  74.        (stricmp (name, KEYMAP_RESNAME))) {
  75.       return (TRUE);
  76.    } else {
  77.       return (FALSE);
  78.    }
  79. }
  80.  
  81. static struct FctEntry {
  82.    struct FctEntry *fe_next;
  83.    char fe_address[16];
  84.    char fe_offsetdec[8];
  85.    char fe_offsethex[8];
  86. //*UHEX*   char fe_offsetuns[8];
  87.    char fe_name[52];
  88. };
  89.  
  90. __asm LONG lfctlist_dspfunc(register __a2 char **array, register __a1 struct FctEntry *entry, register __a0 struct Hook *hook) {
  91.    if (entry) {
  92.       *array++ = entry->fe_offsetdec;
  93.       *array++ = entry->fe_offsethex;
  94. //*UHEX*      *array++ = entry->fe_offsetuns;
  95.       *array++ = entry->fe_address;
  96.       *array   = entry->fe_name;
  97.    } else {
  98.       *array++ = ESC "bOffset";
  99.       *array++ = ESC "bHex";
  100. //*UHEX*      *array++ = ESC "bU-Hex";
  101.       *array++ = ESC "bAddress";
  102.       *array   = ESC "bName";
  103.    }
  104.    return(0);
  105. }
  106.  
  107. struct Hook lfctlist_dsphook = {
  108.  {NULL, NULL},
  109.  (ULONG (* )())lfctlist_dspfunc,
  110.  NULL, NULL
  111. };
  112.  
  113. void GetLDRFctList (struct Library *lib, char mode) {
  114.    struct   WinFree  *ptr;
  115.    unsigned char     *title = "FUNCTIONS: ";
  116.    APTR     lfctlist;
  117.    ULONG    offset, max;
  118.    struct   FctEntry *entry;
  119.    APTR     fctadr;
  120.    BOOL     getfct = (IdentifyBase!=NULL);
  121.    STRPTR   name;
  122.  
  123.    if (ptr = AllocWinFree()) {
  124.       ptr->wf_Window = (APTR) WindowObject,
  125.       MUIA_HelpNode, "Functions",
  126.       MUIA_Window_ID, MakeDetailID('.','L','F','T'),
  127.       WindowContents, VGroup,
  128.          Child, lfctlist = ListviewObject,
  129.             MUIA_Listview_Input, FALSE,
  130.             MUIA_Listview_List, ListObject,
  131.                ReadListFrame,
  132.                MUIA_List_Title, TRUE,
  133.                MUIA_List_Format, "DELTA=8 P=\33r, DELTA=8 P=\33r, DELTA=8,",
  134. //*UHEX*               MUIA_List_Format, "DELTA=8 P=\33r, P=\33r, DELTA=8 P=\33r, DELTA=8,",
  135.                MUIA_List_DisplayHook, &lfctlist_dsphook,
  136.             End,
  137.          End,
  138.       End, End;
  139.  
  140.       if (ptr->wf_Window) {
  141.  
  142.          name = lib->lib_Node.ln_Name;
  143.  
  144.          if( mode!='R' || (
  145.                stricmp(name, FILESYSTEM_RESNAME)
  146.             && stricmp(name, CARD_RESNAME)
  147.             && stricmp(name, KEYMAP_RESNAME))) {
  148.  
  149.             if(!stricmp(name,"ciaa.resource") || !stricmp(name,"ciab.resource"))
  150.               name = "cia.resource";
  151.  
  152.             max = lib->lib_NegSize;
  153.  
  154.             set(lfctlist,MUIA_List_Quiet,TRUE);
  155.  
  156.             for(offset=6; offset <= max; offset+=6) {
  157.               if(entry = AllocRemember (&ptr->wf_RememberKey, sizeof (struct FctEntry), MEMF_ANY|MEMF_CLEAR)) {
  158.  
  159.                  if(*(WORD *)(((UBYTE*)lib) - offset) == 0x4ef9) {
  160.                     fctadr = (APTR) *(LONG *)(((UBYTE *)lib) - offset + 2);
  161.                     if (points2ram(fctadr)) {
  162.                        sprintf (entry->fe_address, HELL "$%08x" DUNKEL, fctadr);
  163.                     } else {
  164.                        sprintf (entry->fe_address, "$%08x", fctadr);
  165.                     }
  166.                  } else {
  167.                     strcpy(entry->fe_address, "<no jmp>");
  168.                  }
  169.  
  170.                  sprintf (entry->fe_offsetdec, "-%3d"  , offset);
  171.                  sprintf (entry->fe_offsethex, "-%04x" , offset);
  172. //*UHEX*                 sprintf (entry->fe_offsetuns, "%04X" , 0x10000-offset);
  173.  
  174.                  if(offset<42 && (mode=='D' || (mode=='L' && offset<30))) {
  175.  
  176.                    STRPTR help;
  177.                    switch(offset) {
  178.                       case  6: help = "Open"   ; break;
  179.                       case 12: help = "Close"  ; break;
  180.                       case 18: help = "Expunge"; break;
  181.                       case 24: help = "Null"   ; break;
  182.                       case 30: help = "AbortIO"; break;
  183.                       case 36: help = "BeginIO"; break;
  184.                    }
  185.                    strcpy(entry->fe_name,help);
  186.  
  187.                  } else if(getfct) {
  188.                     switch(IdFunctionTags(name,offset,IDTAG_FuncNameStr,entry->fe_name,TAG_DONE)) {
  189.                       case IDERR_NOFD:
  190.                       case IDERR_NOMEM:
  191.                          getfct = FALSE;
  192.                          break;
  193.  
  194.                       case IDERR_OFFSET:
  195.                          strcpy(entry->fe_name,"---");
  196.                          break;
  197.                     }
  198.                  }
  199.  
  200.                  InsertBottomEntry (lfctlist, (APTR *) &entry);
  201.  
  202.               }
  203.             }
  204.             set(lfctlist,MUIA_List_Quiet,FALSE);
  205.          }
  206.  
  207.          HandleWindowOpen (ptr, title, lib->lib_Node.ln_Name);
  208.          HandleWindowClose (ptr);
  209.       }
  210.    }
  211. }
  212.  
  213.  
  214. void GetLDRMore (struct Library *lib, char *title, char *helpnode) {
  215.    unsigned char           rpct[4];
  216.    struct   WinFree        *ptr;
  217.    int      teststatus, rpc, i;
  218.  
  219.    APTR libmoretext0,libmoretext1,libmoretext2a,libmoretext2b,libmoretext3,libmoretext4;
  220.    APTR LibMoreAdd1,LibMoreGroup1,LibMoreAdd2,LibMoreGroup2;
  221.  
  222.    UBYTE drflags[]   = {DRF_ALLOC0,DRF_ALLOC1,DRF_ALLOC2,DRF_ALLOC3,
  223.                            DRF_ACTIVE,NULL};
  224.  
  225.    char  *drflagstext[] = {"ALLOC0","ALLOC1","ALLOC2",
  226.                            "ALLOC3","ACTIVE"};
  227.  
  228.    teststatus = TestResource (lib);
  229.  
  230.    if (ptr = AllocWinFree()) {
  231.       if (! stricmp (lib->lib_Node.ln_Name, FILESYSTEM_RESNAME)) {
  232.  
  233.          ptr->wf_Window = (APTR) WindowObject,
  234.  
  235.          MUIA_HelpNode, helpnode,
  236.          MUIA_Window_ID, MakeDetailID('.','L','I','B'),
  237.          WindowContents, HGroup,
  238.             Child, VGroup, MUIA_Group_SameWidth, TRUE,
  239.                Child, MyLabel2 ("Name:"),
  240.                Child, MyLabel2 ("Address:\nPri:"),
  241.                Child, MyLabel2 ("fsr_Creator:"),
  242.             End,
  243.             Child, VGroup,
  244.                Child, MyTextObject3 (FILESYSTEM_RESNAME),
  245.                Child, HGroup,
  246.                   Child, libmoretext1 = MyTextObject(),
  247.                   Child, MyLabel ("Type:"),
  248.                   Child, libmoretext2b = MyTextObject(), 
  249.                End,
  250.                Child, libmoretext3 = MyTextObject(),
  251.             End,
  252.          End, End;
  253.  
  254.          if (ptr->wf_Window) {
  255.             MySetContents (libmoretext1, ESC "c$%08x\n%d", lib, lib->lib_Node.ln_Pri);
  256.             MySetContents (libmoretext2b, ESC "c %s ", GetNodeType (lib->lib_Node.ln_Type));
  257.  
  258.             strcpy (tmpstr, ((struct FileSysResource *) lib)->fsr_Creator);
  259.             healstring (tmpstr);
  260.             set (libmoretext3, MUIA_Text_Contents, tmpstr);
  261.  
  262.             HandleWindowOpen (ptr, title, FILESYSTEM_RESNAME);
  263.             HandleWindowClose (ptr);
  264.          }
  265.       } else if ((! stricmp (lib->lib_Node.ln_Name, CARD_RESNAME)) || \
  266.                  (! stricmp (lib->lib_Node.ln_Name, KEYMAP_RESNAME))) {
  267.          ptr->wf_Window = (APTR) WindowObject,
  268.  
  269.          MUIA_HelpNode, helpnode,
  270.          MUIA_Window_ID, MakeDetailID('.','L','I','B'),
  271.          WindowContents, HGroup,
  272.             Child, VGroup, MUIA_Group_SameWidth, TRUE,
  273.                Child, MyLabel2 ("Name:"),
  274.                Child, MyLabel2 ("Address:\nPri:"),
  275.             End,
  276.             Child, VGroup,
  277.                Child, MyTextObject3 (KEYMAP_RESNAME),
  278.                Child, HGroup,
  279.                   Child, libmoretext1 = MyTextObject(),
  280.                   Child, MyLabel ("Type:"),
  281.                   Child, libmoretext2b = MyTextObject(), 
  282.                End,
  283.             End,
  284.          End, End;
  285.  
  286.          if (ptr->wf_Window) {
  287.             MySetContents (libmoretext1, ESC "c$%08x\n%d", lib, lib->lib_Node.ln_Pri);
  288.             MySetContents (libmoretext2b, ESC "c %s ", GetNodeType (lib->lib_Node.ln_Type));
  289.  
  290.             HandleWindowOpen (ptr, title, KEYMAP_RESNAME);
  291.             HandleWindowClose (ptr);
  292.          }
  293.       } else {
  294.          ptr->wf_Window = (APTR) WindowObject,
  295.  
  296.          MUIA_HelpNode, helpnode,
  297.          MUIA_Window_ID, MakeDetailID('.','L','I','B'),
  298.          WindowContents, HGroup,
  299.             Child, LibMoreGroup1 = VGroup, MUIA_Group_SameWidth, TRUE,
  300.                Child, MyLabel2 ("Name:"),
  301.                Child, MyVSpace(0),
  302.                Child, MyLabel2 ("Address:\nPri:\nType:\nVersion:\nOpenCnt:"),
  303.                Child, MyVSpace(0),
  304.                Child, MyLabel2 ("IdString:"),
  305.             End,
  306.             Child, LibMoreGroup2 = VGroup,
  307.                Child, libmoretext0 = MyTextObject(),
  308.                Child, HGroup,
  309.                   Child, libmoretext1 = MyTextObject(),
  310.                   Child, VGroup,
  311.                      Child, MyLabel ("Flags:"),
  312.                      Child, MyLabel ("NegSize:\nPosSize:\nSum:\nRamPtrCnt:"),
  313.                   End,
  314.                   Child, VGroup,
  315.                      Child, libmoretext2a = KeyButtonF ('b', lib->lib_Flags),
  316.                      Child, libmoretext2b = MyTextObject(),
  317.                   End,
  318.                End,
  319.                Child, libmoretext3 = MyTextObject(),
  320.             End,
  321.          End, End;
  322.  
  323.          if (ptr->wf_Window) {
  324.             if ((rpc = GetRamPointerCount (lib)) == (lib->lib_NegSize / 6)) {
  325.                strcpy (rpct, "***");
  326.             } else {
  327.                sprintf (rpct, "%d", rpc);
  328.             }
  329.             MySetContents (libmoretext1, ESC "c$%08x\n%d\n%s\n%d.%d\n%d", lib, lib->lib_Node.ln_Pri, GetNodeType (lib->lib_Node.ln_Type), lib->lib_Version, lib->lib_Revision, lib->lib_OpenCnt);
  330.             MySetContents (libmoretext2b, ESC "c%d\n%d\n$%08x\n%s", lib->lib_NegSize, lib->lib_PosSize, lib->lib_Sum, rpct);
  331.  
  332.             if (! stricmp (lib->lib_Node.ln_Name, DISK_RESNAME)) {
  333.                Child, LibMoreAdd1 = VGroup, MUIA_Group_SameWidth, TRUE,
  334.                   Child, MyLabel2 ("dr_Current:"),
  335.                   Child, MyLabel2 ("dr_CurrTask:"),
  336.                End;
  337.  
  338.                Child, LibMoreAdd2 = VGroup,
  339.                   Child, libmoretext4 = MyTextObject(),
  340.                   Child, MyTextObject3 (GetTaskName (((struct DiscResource *) lib)->dr_CurrTask)),
  341.                End;
  342.  
  343.                tmpstr[0] = '\0';
  344.                i = 0;
  345.                while (drflags[i]) {
  346.                   if (((struct DiscResource *) lib)->dr_Flags & drflags[i]) {
  347.                      if (strlen (tmpstr))
  348.                         strcat (tmpstr, ", ");
  349.                      strcat (tmpstr, drflagstext[i]);
  350.                   }
  351.                   i++;
  352.                }
  353.                set (libmoretext4, MUIA_Text_Contents, nonetest (tmpstr));
  354.                DoMethod (LibMoreGroup1,OM_ADDMEMBER,LibMoreAdd1);
  355.                DoMethod (LibMoreGroup2,OM_ADDMEMBER,LibMoreAdd2);
  356.             }
  357.  
  358.             HandleFlagsButtonPressed (libmoretext2a, ptr, "(LIBRARY)", "lib_Flags", lib->lib_Flags, (struct LongFlag *) &lib_flags, NULL, 'b');
  359.             HandleWindowOpen (ptr, title, lib->lib_Node.ln_Name);
  360.             MySetContentsHealed (libmoretext0, "%s", lib->lib_Node.ln_Name);
  361.             MySetContentsHealed (libmoretext3, "%s", nonetest (lib->lib_IdString));
  362.             HandleWindowClose (ptr);
  363.          }
  364.       }
  365.    }
  366. }
  367.  
  368. void GetLibMore (struct Library *lib) {
  369.    char *title = "LIBRARY: ";
  370.  
  371.    GetLDRMore (lib, title, LibrariesText);
  372. }
  373.  
  374. void GetDevMore (struct Library *lib) {
  375.    char *title = "DEVICE: ";
  376.  
  377.    GetLDRMore (lib, title, DevicesText);
  378. }
  379.  
  380. void GetResMore (struct Library *lib) {
  381.    char *title = "RESOURCE: ";
  382.  
  383.    GetLDRMore (lib, title, ResourcesText);
  384. }
  385.  
  386. void PrintLDR (APTR list, char type, char *filename) {
  387.    int   i;
  388.    BPTR  handle;
  389.    struct LibEntry *entryp;
  390.  
  391.    handle = HandlePrintStart (filename);
  392.    if ((handle) && (PrintOneLine (handle, "\n  Address   Pri OpenC RPC Name & Version\n\n"))) {
  393.       if ((type == 'L') && (! WI_Libraries)) {
  394.          i = FillLDRList ('L', &entryp);
  395.       } else if ((type == 'D') && (! WI_Devices)) {
  396.          i = FillLDRList ('D', &entryp);
  397.       } else if ((type == 'R') && (! WI_Resources)) {
  398.          i = FillLDRList ('R', &entryp);
  399.       }
  400. //      if (i) {
  401.          for (i=0;;i++) {
  402.  
  403.             if (((type == 'L') && (WI_Libraries)) \
  404.                || ((type == 'D') && (WI_Devices)) \
  405.                || ((type == 'R') && (WI_Resources))) {
  406.                DoMethod (list,MUIM_List_GetEntry,i,&entryp);
  407.             }
  408.             if (!entryp) break;
  409.  
  410.             sprintf (tmpstr2, " %ls %4ls %4ls %3ls %ls %ld.%ld\n", entryp->lib_address, entryp->lib_pri, entryp->lib_ocnt, entryp->lib_rcnt, entryp->lib_name, ((struct Library *) entryp->lib_ptr)->lib_Version, ((struct Library *) entryp->lib_ptr)->lib_Revision);
  411.             if (! (PrintOneLine (handle, tmpstr2)))
  412.                break;
  413.  
  414.             if (((type == 'L') && (! WI_Libraries)) \
  415.                || ((type == 'D') && (! WI_Devices)) \
  416.                || ((type == 'R') && (! WI_Resources))) {
  417.                entryp = entryp->lib_next;
  418.             }
  419.          }
  420. //      }
  421.    }
  422.    HandlePrintStop();
  423. }
  424.  
  425. void PrintLibraries (char *filename) {
  426.    PrintLDR (liblist,'L',filename);
  427. }
  428.  
  429. void PrintDevices (char *filename) {
  430.    PrintLDR (devlist,'D',filename);
  431. }
  432.  
  433. void PrintResources (char *filename) {
  434.    PrintLDR (reslist,'R',filename);
  435. }
  436.  
  437. int FillLDRList (char kind, struct LibEntry **first) {
  438.    struct   Library  *lib;
  439.    APTR     list;
  440.    struct   Remember **key;
  441.    char     *cmd;
  442.  
  443.    struct   LibEntry   *libentry,*previous = NULL;
  444.    int      tmp,teststatus;
  445.  
  446.    int libcnt = 0;
  447.    *first = 0;
  448.  
  449.    if (kind == 'L') {
  450.       FreeLibraries ();
  451.       key = &LibRememberKey;
  452.       lib = FIRSTLIBRARY;
  453.       list = liblist;
  454.       cmd = "GetLibList";
  455.    } else if (kind == 'D') {
  456.       FreeDevices ();
  457.       key = &DevRememberKey;
  458.       lib = FIRSTDEVICE;
  459.       list = devlist;
  460.       cmd = "GetDevList";
  461.    } else if (kind == 'R') {
  462.       FreeResources ();
  463.       key = &ResRememberKey;
  464.       lib = FIRSTRESOURCE;
  465.       list = reslist;
  466.       cmd = "GetResList";
  467.    }
  468.  
  469.    if (clientstate) {
  470.       if (SendDaemon (cmd)) {
  471.          while ((libentry = AllocRemember (key, sizeof (struct LibEntry), MEMF_ANY|MEMF_CLEAR)) \
  472.            && (ReceiveDecodedEntry ((UBYTE *) libentry, sizeof (struct LibEntry)))) {
  473.             IsHex (libentry->lib_address, (long *) &libentry->lib_ptr);
  474.  
  475.             if (! *first)
  476.                *first = libentry;
  477.             if (previous)
  478.                previous->lib_next = libentry;
  479.  
  480.             libcnt++;
  481.             previous = libentry;
  482.          }
  483.       }
  484.    } else {
  485.       while ((lib->lib_Node.ln_Succ != 0) && (libentry = AllocRemember (key, sizeof (struct LibEntry), MEMF_ANY|MEMF_CLEAR))) {
  486.          if (! *first)
  487.             *first = libentry;
  488.          if (previous)
  489.             previous->lib_next = libentry;
  490.    
  491.          libentry->lib_ptr = (char *) lib;
  492.          sprintf (libentry->lib_address, "$%08x",lib);
  493.          strncpy (libentry->lib_name, lib->lib_Node.ln_Name, 30);
  494.          sprintf (libentry->lib_pri, "%4d ", lib->lib_Node.ln_Pri);
  495.    
  496.          teststatus = TestResource (lib);
  497.    
  498.          if (teststatus) {
  499.             sprintf (libentry->lib_ocnt, "%3d ", lib->lib_OpenCnt);
  500.             if ((tmp = GetRamPointerCount(lib)) == (lib->lib_NegSize / 6)) {
  501.                strcpy (libentry->lib_rcnt, "***");
  502.             } else {
  503.                sprintf (libentry->lib_rcnt, "%3d", tmp);
  504.             }
  505.          } else {
  506.             strcpy (libentry->lib_ocnt, "--- ");
  507.             strcpy (libentry->lib_rcnt, "---");
  508.          }
  509.          strcpy (libentry->lib_type, GetNodeType (lib->lib_Node.ln_Type));
  510.    
  511.          libcnt++;
  512.          previous = libentry;
  513.          lib = (struct Library *)lib->lib_Node.ln_Succ;
  514.       }
  515.    }
  516.    return (libcnt);
  517. }
  518.  
  519. void FreeLibraries (void) {
  520.    MyFreeStructs (&LibRememberKey, libtext, liblist);
  521. }
  522.  
  523. void FlushLibraries (void) {
  524.    struct   Library  *lib,*next;
  525.  
  526.    lib = FIRSTLIBRARY;
  527.  
  528.    while (next = (struct Library *) lib->lib_Node.ln_Succ) {
  529.       if (! lib->lib_OpenCnt)
  530.          RemLibrary (lib);
  531.       lib = next;
  532.    }
  533. }
  534.  
  535. void FreeDevices (void) {
  536.    MyFreeStructs (&DevRememberKey, devtext, devlist);
  537. }
  538.  
  539. void FlushDevices (void) {
  540.    struct   Library  *lib,*next;
  541.  
  542.    lib = FIRSTDEVICE;
  543.  
  544.    while (next = (struct Library *) lib->lib_Node.ln_Succ) {
  545.       if (! lib->lib_OpenCnt)
  546.          RemDevice ((struct Device *) lib);
  547.       lib = next;
  548.    }
  549.    
  550. }
  551.  
  552. void FreeResources (void) {
  553.    MyFreeStructs (&ResRememberKey, restext, reslist);
  554. }
  555.  
  556. void ShowLibraries (void) {
  557.    struct   LibEntry    *lib;
  558.  
  559.         ApplicationSleep();
  560.         set(liblist,MUIA_List_Quiet,TRUE);
  561.    set(liblist,MUIA_List_CompareHook,liblist_cmphook_ptr);
  562.    set(BT_LibRemove, MUIA_Disabled, TRUE);
  563.    set(BT_LibClose, MUIA_Disabled, TRUE);
  564.    set(BT_LibPriority, MUIA_Disabled, TRUE);
  565.    set(BT_LibFunctions, MUIA_Disabled, TRUE);
  566.    set(BT_LibMore, MUIA_Disabled, TRUE);
  567.  
  568.    libcnt = FillLDRList ('L', &lib);
  569.  
  570.         while (lib) {
  571.       InsertSortedEntry (liblist, (APTR *) &lib);
  572.       lib = lib->lib_next;
  573.    }
  574.  
  575.    SetCountText (libcount, libcnt);
  576.         AwakeApplication();
  577.         set(liblist,MUIA_List_Quiet,FALSE);
  578. }
  579.  
  580. void ShowDevices (void) {
  581.    struct   LibEntry    *lib;
  582.  
  583.         ApplicationSleep();
  584.         set(devlist,MUIA_List_Quiet,TRUE);
  585.    set(devlist,MUIA_List_CompareHook,devlist_cmphook_ptr);
  586.    set(BT_DevRemove, MUIA_Disabled, TRUE);
  587.    set(BT_DevPriority, MUIA_Disabled, TRUE);
  588.    set(BT_DevFunctions, MUIA_Disabled, TRUE);
  589.    set(BT_DevMore, MUIA_Disabled, TRUE);
  590.  
  591.    devcnt = FillLDRList ('D', &lib);
  592.  
  593.         while (lib) {
  594.       InsertSortedEntry (devlist, (APTR *) &lib);
  595.       lib = lib->lib_next;
  596.    }
  597.  
  598.    SetCountText (devcount, devcnt);
  599.         AwakeApplication();
  600.         set(devlist,MUIA_List_Quiet,FALSE);
  601. }
  602.  
  603. void ShowResources (void) {
  604.    struct   LibEntry    *lib;
  605.  
  606.         ApplicationSleep();
  607.         set(reslist,MUIA_List_Quiet,TRUE);
  608.    set(reslist,MUIA_List_CompareHook,reslist_cmphook_ptr);
  609.    set(BT_ResRemove, MUIA_Disabled, TRUE);
  610.    set(BT_ResPriority, MUIA_Disabled, TRUE);
  611.    set(BT_ResFunctions, MUIA_Disabled, TRUE);
  612.    set(BT_ResMore, MUIA_Disabled, TRUE);
  613.  
  614.    rescnt = FillLDRList ('R', &lib);
  615.  
  616.         while (lib) {
  617.       InsertSortedEntry (reslist, (APTR *) &lib);
  618.       lib = lib->lib_next;
  619.    }
  620.  
  621.    SetCountText (rescount, rescnt);
  622.         AwakeApplication();
  623.         set(reslist,MUIA_List_Quiet,FALSE);
  624. }
  625.  
  626. void SendLibList (void) {
  627.    struct   LibEntry    *lib;
  628.  
  629.    FillLDRList ('L', &lib);
  630.  
  631.         while (lib) {
  632.       SendEncodedEntry ((UBYTE *) lib, sizeof (struct LibEntry));
  633.       lib = lib->lib_next;
  634.    }
  635.    FreeLibraries ();
  636. }
  637.  
  638. void SendDevList (void) {
  639.    struct   LibEntry    *lib;
  640.  
  641.    FillLDRList ('D', &lib);
  642.  
  643.         while (lib) {
  644.       SendEncodedEntry ((UBYTE *) lib, sizeof (struct LibEntry));
  645.       lib = lib->lib_next;
  646.    }
  647.    FreeDevices ();
  648. }
  649.  
  650. void SendResList (void) {
  651.    struct   LibEntry    *lib;
  652.  
  653.    FillLDRList ('R', &lib);
  654.  
  655.         while (lib) {
  656.       SendEncodedEntry ((UBYTE *) lib, sizeof (struct LibEntry));
  657.       lib = lib->lib_next;
  658.    }
  659.    FreeResources ();
  660. }
  661.  
  662.